
import { ApiProvider } from "../../providers/api/api";

import { Injectable } from '@angular/core';
import { Component, OnInit ,Input} from '@angular/core';
import {Observable} from "rxjs/Observable";
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/throttleTime';
import 'rxjs/add/observable/fromEvent';
import 'rxjs/add/operator/retry';
import { observable } from "rxjs/symbol/observable";
import { UpgradeAppProvider } from "../../providers/upgrade-app/upgrade-app";
@Injectable()
/**
 * Generated class for the PageControlComponent component.
 *
 * See https://angular.io/api/core/Component for more info on Angular
 * Components.
 */
@Component({
  selector: 'page-control',
  templateUrl: 'page-control.html'
})
export class PageControlComponent {

  @Input()  unitId;//共多少条数据
  @Input()  classcourseId;//共多少条数据
  constructor(private wsService: UpgradeAppProvider,public http:ApiProvider) { }

  ngAfterViewInit() {
    //this.httpreq._get('',(data)=>console.log(data));
    this.wsService.createObservableSocket(`${this.http.sendwsinfo}/FourInOneTeacherMgt/websocket`)//'ws://192.168.0.28:8080/FourInOneTeacherMgt/websocket'
      .subscribe(
        data => console.log(data),
        err => console.log(err),
        () => console.log('it s over')
      )
  }

  sendMessageToServer(sta) {
    if (sta == "pre") {
      console.log(147)
      console.log(`${this.classcourseId},${this.unitId}`)
      this.wsService.sendMessage(`preAnim,${this.classcourseId},${this.unitId}`);
    } else if (sta == "next") {
      this.wsService.sendMessage(`nextAnim,${this.classcourseId},${this.unitId}`);
    }

  }




}
